<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Ward_Model extends CI_Model
{
    protected $_lang = '';
    protected $_table = "aw_ward";
    
    function __construct() {
        parent::__construct();
    }
    public function initialise($lang)
    {
        if($lang!=''&&$lang!='vn')
            $this->_lang = '_'.$lang;
        else
            $this->_lang = '';
    }
   
    function getAllWard($district_id = 0){
        
        if(!empty($district_id)) {
            $this->db->select('ward_id, name,type');
            $this->db->where('district_id', $district_id);
            $this->db->where('bl_active', 1);
            $this->db->order_by('name','ASC');

            return $this->db->get($this->_table)->result();
        }
        return;
    }
	function optionWard($district_id=0,$value=0){
		   $query = $this->db->get_where('ward', array('district_id' =>$district_id));
		   $category_arr = $query->result();
		   $str_opt = "<option value=''> Chọn Phường/Xã</option>";
		   foreach($category_arr as $item_opt){
				$str_opt .="<option value='".$item_opt->ward_id."'".(($value==$item_opt->ward_id)?" selected":"")."> ".$item_opt->type.' '.$item_opt->name."</option>";
			}
			return $str_opt;
	   }

	
}